﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Robin.Domain.Entities;
using Robin.NHibernate.EntityMappings;

namespace Smart.Project.Data
{
    public class MEventMap : EntityMap<MEvent, string>
    {
        public MEventMap() : base("PM_EVENT")
        {
            Id(x => x.Id);
            Map(x => x.EVENTNAME);
            Map(x => x.EVENTTIME);
            Map(x => x.DEPICT);
            References(o => o.TAG).Not.LazyLoad().Column("TAGID");
            References(o => o.MANAGER).Not.LazyLoad().Column("MANAGER");
            References(o => o.PROJECTID).Not.LazyLoad().Column("PROJECTID");
        }
    }
    /// <summary>
    /// 部门
    /// </summary>
    public class MEvent : Entity<string>
    {
        /// <summary>
        /// 事件名称
        /// </summary>
        public virtual string EVENTNAME { get; set; }
        /// <summary>
        /// 项目ID
        /// </summary>
        public virtual MProjectinfo PROJECTID { get; set; }
        /// <summary>
        /// 参与人
        /// </summary>
        public virtual MUser MANAGER { get; set; }
        /// <summary>
        /// 标签ID
        /// </summary>
        public virtual MTag TAG { get; set; }

        /// <summary>
        /// 事件时间
        /// </summary>
        public virtual Decimal EVENTTIME { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public virtual string DEPICT { get; set; }
        /// <summary>
        /// 序号
        /// </summary>
        public virtual Decimal NUMBER { get; set; }
        /// <summary>
        /// 事件时间格式转换
        /// </summary>
        public virtual string EVENTTIMETYPE
        { get
            {
                EVENTTIME = EVENTTIME==0?decimal.Parse(DateTime.Now.ToString("yyyyMMddHHmmss")): EVENTTIME;
                return DateTime.ParseExact(EVENTTIME.ToString(), "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy-MM-dd HH:mm:ss");
            }
            set
            {
                EVENTTIME = Decimal.Parse(DateTime.Parse(value).ToString("yyyyMMddHHmmss"));
            }
        }

    }

}
